package com.leadzone.websocket;

import java.util.HashSet;
import java.util.Set;

import javax.websocket.Endpoint;
import javax.websocket.server.ServerApplicationConfig;
import javax.websocket.server.ServerEndpointConfig;

public class socketConfig implements  ServerApplicationConfig {

	 
   
	/* (non-Javadoc) 注册 注释类 url 路径见@ServerEndpoint
	 * @see javax.websocket.server.ServerApplicationConfig#getAnnotatedEndpointClasses(java.util.Set)
	 */
	@Override
	public Set<Class<?>> getAnnotatedEndpointClasses(Set<Class<?>> scanned) {
	     Set<Class<?>> results = new HashSet<Class<?>>();
	        for (Class<?> clazz : scanned) {
	        	System.out.println(clazz.getName());
	        	System.out.println(clazz.getPackage());
	            if (clazz.getPackage().getName().startsWith("com.")) {
	            	System.out.println(clazz.getName());
	                results.add(clazz);
	            }
	        }
		return results;
 
	}
	/* (non-Javadoc) 注册 Endpoint继承类 url 路径见  path参数
	 * @see javax.websocket.server.ServerApplicationConfig#getAnnotatedEndpointClasses(java.util.Set)
	 */
	@Override
	public Set<ServerEndpointConfig> getEndpointConfigs(Set<Class<? extends Endpoint>> scanned) {
		  Set<ServerEndpointConfig> result = new HashSet<ServerEndpointConfig>();

	        if (scanned.contains(EndPointSoeket.class)) {
	            result.add(ServerEndpointConfig.Builder.create(
	            		EndPointSoeket.class,
	                    "/websocket/echoProgrammatic").build());
	        }
		return result;
	}

}
